package framework.drawer.swing;

import ilm.framework.gui.BaseGUI;

import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;

import framework.drawer.swing.gui.SideBar;
import framework.drawer.swing.gui.SideBarUI;
import framework.view.BaseDrawer;
import framework.view.BaseMenu;
import framework.view.BaseMenuGroup;
import framework.view.BaseWindow;


public class SwingDrawer extends BaseDrawer {
    
    private JFrame jWindow;
    private SideBar menu;

    public void newMenu(BaseMenu menu) {
    	List<BaseMenuGroup> groups = new ArrayList<BaseMenuGroup>();
    	groups.add(menu.getMainMenu());
    	for(BaseMenuGroup b : (List<BaseMenuGroup>)menu.getAditionalMenus())
    		groups.add(b);
    	this.menu = new SideBar(groups);
    	new SideBarUI(this.menu);
    	jWindow.add(this.menu, BorderLayout.EAST);
    }


    public void newWindow(BaseWindow window, BaseGUI ilm) {
    	jWindow = new JFrame();
        jWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jWindow.setSize(window.getW(), window.getH());
        jWindow.setTitle(window.getLabel());
        jWindow.setLocationRelativeTo(null);
        jWindow.setContentPane(ilm);
        jWindow.setVisible(true);
    }
}
